package actionId;

public class ActionIdGenerator {
    int rawCode;
    int subject;
    int predicate;
    int localC;
    int modalC;
    int directC;
    
    String name;
    String timestamp;
    
    public ActionIdGenerator(int s, int p, int l, int m, int d)
    {
        subject = s;
        predicate = p;
        localC = l;
        modalC = m;
        directC = d;
    }
    
    public ActionIdGenerator(int raw)
    {
        rawCode = raw;
    }
    
    public void build()
    {
        subject = (rawCode/1000000) % 10;
        predicate = (rawCode/10000) % 100;
        localC = (rawCode/1000) % 10;
        directC = (rawCode/10) % 100;
        modalC = rawCode % 10;
        rawCode = 0;
    }
    
    public int getRawCode()
    {
        if (rawCode != 0)
        {
            return rawCode;
        }
        else
        {
            return generateRawCode();
        }
    }
    
    private int generateRawCode()
    {
        rawCode  = subject * 1000000 + predicate * 10000 + localC * 1000 + directC * 10 + modalC; 
        return rawCode;
    }
    
    public int getSubject()
    {
        return subject;
    }
    
    public int getPredicate()
    {
        return predicate;
    }
    
    public int getLocalC()
    {
        return localC;
    }
    
    public int getModalC()
    {
        return modalC;
    }
    
    public int getDirectC()
    {
        return directC;
    }
    
    public void setName(String n)
    {
        name = n;
    }
    
    public void setTimestamp(String t)
    {
        timestamp = t;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getTimestamp()
    {
        return timestamp;
    }
    
    public String toString()
    {     
        return name;
    }
}
